import java.util.*;
public class LinkeListCollection {
	public static void linkListMethod() {
		// Create and initialize linked list
	      LinkedList<Integer> ll = new LinkedList<Integer>();
	      ll.add(new Integer(-8));
	      ll.add(new Integer(20));
	      ll.add(new Integer(-20));
	      ll.add(new Integer(8));
	      
	      System.out.println("Link List implementation.");
	      Iterator<Integer> its = ll.iterator();
	      System.out.println("Element in linkedList\n ");
	      while(its.hasNext()) {
	    	  System.out.println(" "+ its.next());
	      }
	    		  
	      // Create a reverse order comparator
	      Comparator<Integer> r = Collections.reverseOrder();
	      // Sort list by using the comparator
	      Collections.sort(ll, r);
	      // Get iterator
	      Iterator<Integer> li = ll.iterator();
	     
	      System.out.print("List sorted in reverse: ");
	      while(li.hasNext()){
	         System.out.print(li.next() + " ");
	      }
	      System.out.println();
	      Collections.shuffle(ll);
	      // display randomized list
	      li = ll.iterator();
	      System.out.print("List shuffled: ");
	      while(li.hasNext()){
	         System.out.print(li.next() + " ");
	      }
	      System.out.println();
	      System.out.println("Minimum: " + Collections.min(ll));
	      System.out.println("Maximum: " + Collections.max(ll));
	
	}
}
